package com.ruoyi.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.wms.domain.EndLifeVehicleBase;
import com.ruoyi.wms.dto.EndLifeVehicleDto;
import com.ruoyi.wms.dto.UpdateEndLifeVehicleStatusDTO;
import com.ruoyi.wms.service.IEndLifeVehicleService;
import com.ruoyi.wms.vo.EndLifeVehicleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
/**
 * 报废车辆信息Controller
 *
 * @author libancang
 * @date 2025-09-12
 */

@Api(value = "报废车辆信息Controller", tags = "报废车辆信息基础信息 也就是商品")
@RestController
@RequestMapping("/endLifeVehicle")
public class EndLifeVehicleController extends BaseController {
    @Autowired
    private IEndLifeVehicleService endLifeVehicleService;

    /**
     * 查询报废车辆信息列表
     */
//    @RequiresPermissions("lvlain:endLifeVehicle:list")
    @GetMapping("/list")
    public TableDataInfo list(EndLifeVehicleDto endLifeVehicle) {
        startPage();
        List<EndLifeVehicleBase> list = endLifeVehicleService.selectEndLifeVehicleList(endLifeVehicle);
        return getDataTable(list);
    }




    @ApiOperation("获取司机信息详细信息息getInfoById")
    @GetMapping(value = "/getInfoByplateNo")
    public AjaxResult getInfoByplateNo(@ApiParam(value = "车牌号码", required = true) @RequestParam(value = "plateNo") String plateNo) {
        return success(endLifeVehicleService.selectEndLifeVehicleById(plateNo));
    }


    /**
     * 修改报废车辆信息
     */
    @RequiresPermissions("lvlain:endLifeVehicle:edit")
    @Log(title = "报废车辆信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EndLifeVehicleBase endLifeVehicle) {
        return toAjax(endLifeVehicleService.updateEndLifeVehicle(endLifeVehicle));
    }

    /**
     * 删除报废车辆信息
     */


    @ApiOperation("采购台账 报废汽车")
    @GetMapping("/queryProcurementLedgerList")
    public TableDataInfo queryProcurementLedgerList(EndLifeVehicleDto endLifeVehicle) {
        startPage();
        List<EndLifeVehicleVo> list = endLifeVehicleService.queryProcurementLedgerList(endLifeVehicle);
        return getDataTable(list);
    }


    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody String[] ids) {
        if (ids == null || ids.length == 0) {
            return error("未选中");
        }
        int i = endLifeVehicleService.deleteEndLifeVehicleByIds(ids);
        if (i > 0) {
            return success("删除成功");
        }
        return toAjax(i);
    }

    //RequestParam 表单提交
    @RequiresPermissions("wms:endLifeVehicle:updateEndLifeVehicleStatus")
    @ApiOperation("修改报废汽车车辆状态 有 待查验 待过磅 待质检 待注销 待付款 待拆解 待完善 拆解中 完结")
    @PostMapping("/updateEndLifeVehicleStatus")
    public AjaxResult updateEndLifeVehicleStatus(@RequestBody UpdateEndLifeVehicleStatusDTO dto) {
//确认付款  确认注销
//        confirmPayment

        if (dto.getIds() == null || dto.getIds().length == 0) {
            return error("未选中");
        }
        int i = endLifeVehicleService.updateEndLifeVehicleStatus(dto);
        if (i > 0) {
            return success("修改成功");
        }
        return toAjax(i);
    }
//根据订单号查车辆列表


    /**
     * 获取报废车辆信息详细信息
     */
//    @RequiresPermissions("lvlain:endLifeVehicle:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(endLifeVehicleService.selectEndLifeVehicleById(id));
    }

    /**
     * 生成二维码，内容为 /api/xxx/{id} 形式的接口地址
     */
    /**
     * 生成二维码，内容为完整接口URL
     */
}
